#define _CRT_SECURE_NO_WARNINGS 1

class Solution
{
public:
    string mergeAlternately(string word1, string word2)
    {
        string s;
        int n = word1.size();
        int m = word2.size();
        int i = 0, j = 0, k = 1;

        while (i < n || j < m)
        {
            if (i < n)
            {
                s.push_back(word1[i]);
                ++i;
            }
            if (j < m) {
                s.push_back(word2[j]);
                ++j;
            }
        }

        return s;
    }
};